package com.yunhe.abnormal.repository.base;

import com.yunhe.abnormal.domain.base.AbnormalStatus;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface AbnormalStatusRepository extends Neo4jRepository<AbnormalStatus, Long> {

    AbnormalStatus findByName(String name);

    AbnormalStatus findByCode(Long code);

    @Query("match(a:AbnormalStatus{code:{code}}) match(b:AlarmStatus{code:{statusCode}}) create(b)-[:ABNORMALTYPE_OF]->(a)")
    void bindAlarmStatus(@Param("code") Long code, @Param("statusCode") Long statusCode);
}
